﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="QuanLyTinTuc.aspx.cs" Inherits="admin_QuanLyTinTuc" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentNoiDung" runat="Server">
    <div id="main-content">
        <!-- Main Content Section with everything -->
        <!-- Page Head -->
        <div class="content-box">
            <div class="content-box-header">
                <h3 style="cursor: s-resize;">
                    Tin tức</h3>
                <ul class="content-box-tabs">
                    <li><a href="#tab1" class="default-tab current">Danh sách</a></li>
                    <!-- href must be unique and match the id of target div -->
                    <li><a href="#tab2">Thêm mới</a></li>
                </ul>
                <div class="clear">
                </div>
            </div>
            <!-- End .content-box-header -->
            <div class="content-box-content">
                <div class="tab-content default-tab" id="tab1" style="display: block;">
                    <div class="formleft">
                        <div class="formleft">
                            <p>
                                <label>
                                    Loại tin</label>
                                <asp:DropDownList runat="server" ID="ddlLoaiBai" AutoPostBack="true" OnSelectedIndexChanged="ddlLoaiBai_OnSelectedIndexChanged">
                                </asp:DropDownList>
                            </p>
                        </div>
                        <div class="formright">
                            <p>
                                <label>
                                    Ngôn ngữ</label>
                                <asp:DropDownList runat="server" ID="ddlLang" AutoPostBack="true" OnSelectedIndexChanged="ddlLang_OnSelectedIndexChanged">
                                </asp:DropDownList>
                            </p>
                        </div>
                    </div>
                            <div class="formright">
                            <p>
                                    <label>
                                        Hình ảnh</label>
                                    <input type="file" id="File1" name="inputFile" runat="server" />
                                    <asp:CheckBox id="chkDeleteFile" runat="server" Text="Delete"/>
                                    <asp:TextBox ID="TextBox1" runat="server" Width="450px" Visible="false">
                                    </asp:TextBox>
                                </p>
                                <p>
                            <input type="image" width="200px" heigh="200px" id="imageDemons" name="imageDemons" runat="server" src="/images/noimage.jpg" />
                                <asp:Button runat="server" ID="Button1" CssClass="button" Text="Thay hình" OnClick="btnUpload_OnClick" />
                                </p>
                            </div>
                    <!-- This is the target div. id must match the href of this div's tab -->
                    <table>
                        <thead>
                            <tr>
                                <th>
                                    Tiêu đề
                                </th>
                                <th>
                                    Loại
                                </th>
                                <th>
                                    Ngôn ngữ
                                </th>
                                <th>
                                </th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td colspan="4">
                                    <p style="font-weight: bold; margin-left: 30px; color: #545454; font-size: 12px;
                                        text-align: right">
                                        Tổng cộng:
                                        <asp:Label ID="ResultCount" runat="server"></asp:Label>
                                        tin
                                    </p>
                                    <center>
                                        <div style="font-size: 12px">
                                            <%if (TotalRecord > PagingSize)
                                              {%>
                                            <!-- Paging { -->
                                            <ul class="paginator">
                                                <%= PageString%>
                                            </ul>
                                            <!-- } Paging -->
                                            <%} %>
                                        </div>
                                    </center>
                                    <%--										<div class="pagination">
											<a href="#" title="First Page">« First</a><a href="#" title="Previous Page">« Previous</a>
											<a href="#" class="number" title="1">1</a>
											<a href="#" class="number" title="2">2</a>
											<a href="#" class="number current" title="3">3</a>
											<a href="#" class="number" title="4">4</a>
											<a href="#" title="Next Page">Next >></a><a href="#" title="Last Page">Last »</a>
										</div> <!-- End .pagination -->
                                        --%>
                                    <div class="clear">
                                    </div>
                                </td>
                            </tr>
                        </tfoot>
                        <tbody>
                            <asp:Repeater ID="repSanPham" runat="server" OnItemDataBound="repSanPham_OnItemDataBound">
                                <ItemTemplate>
                                    <tr class="alt-row">
                                        <td>
                                            <a href='ChiTietTinTuc.aspx?mode=edit&id=<%#Eval("ID")%>'>
                                                <%#Eval("Ten")%>
                                            </a>
                                        </td>
                                        <td style="vertical-align: middle">
                                            <%#GetTenLoai(Eval("Loai"))%>
                                        </td>
                                        <td style="vertical-align: middle">
                                            <%#LoaiDataHelper.GetTenNgonNgu(Eval("Lang"))%>
                                        </td>
                                        <td style="vertical-align: middle">
                                            <!-- Icons -->
                                            <a href='ChiTietTinTuc.aspx?mode=edit&id=<%#Eval("ID")%>' title="Edit">
                                                <img src="resources/images/icons/pencil.png" alt="Edit"></a>
                                            <asp:Button ID="learnMoreButton" CssClass="button" runat="server" Text="Xóa" CommandArgument='<%#Eval("ID")%>'
                                                OnClick="learnMoreButton_Click" UseSubmitBehavior="False" BorderStyle="None" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <AlternatingItemTemplate>
                                    <tr class="">
                                        <td>
                                            <a href='ChiTietTinTuc.aspx?mode=edit&id=<%#Eval("ID")%>'>
                                                <%#Eval("Ten")%>
                                            </a>
                                        </td>
                                        <td style="vertical-align: middle">
                                            <%#GetTenLoai(Eval("Loai"))%>
                                        </td>
                                        <td style="vertical-align: middle">
                                            <%#LoaiDataHelper.GetTenNgonNgu(Eval("Lang"))%>
                                        </td>
                                        <td style="vertical-align: middle">
                                            <!-- Icons -->
                                            <a href='ChiTietTinTuc.aspx?mode=edit&id=<%#Eval("ID")%>' title="Edit">
                                                <img src="resources/images/icons/pencil.png" alt="Edit"></a>
                                            <asp:Button ID="learnMoreButton" CssClass="button" runat="server" Text="Xóa" CommandArgument='<%#Eval("ID")%>'
                                                OnClick="learnMoreButton_Click" UseSubmitBehavior="False" BorderStyle="None" />
                                        </td>
                                    </tr>
                                </AlternatingItemTemplate>
                            </asp:Repeater>
                        </tbody>
                    </table>
                </div>
                <!-- End #tab1 -->
                <div class="tab-content" id="tab2" style="display: none;">
                    <form action="" method="post">
                    <fieldset>
                        <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                        <div class="formleft">
                            <p>
                                <label>
                                    Tiêu đề</label>
                                <asp:TextBox ID="txtTenSanPham" MaxLength="100" runat="server" CssClass="text-input large-input"></asp:TextBox>
                            </p>
                            <div class="formleft">
                                <p>
                                    <label>
                                        Loại tin</label>
                                    <asp:DropDownList runat="server" ID="ddlLoaiBai1">
                                    </asp:DropDownList>
                                </p>
                            </div>
                            <div class="formleft">
                                <p>
                                    <label>
                                        Ngôn ngữ</label>
                                    <asp:DropDownList runat="server" ID="ddlLang1">
                                    </asp:DropDownList>
                                </p>
                            </div>
                        </div>
                        <div class="formright">
                            <p>
                                <label>
                                    Hình ảnh</label>
                                <input type="file" id="inputFile" name="inputFile" runat="server" />
                                <asp:TextBox ID="txtHinhAnh" runat="server" Width="450px" Visible="false">
                                </asp:TextBox>
                            </p>
                        </div>
                        <div style="padding-top: 130px;">
                            <p>
                                <table>
                                    <tr>
                                        <td>
                                            Mô tả :
                                        </td>
                                        <td>
                                            <asp:TextBox runat="server" ID="txtMoTa" MaxLength="140" TextMode="MultiLine"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </p>
                        </div>
                        <div>
                            <p>
                                <table>
                                    <tr>
                                        <td>
                                            Nội dung :
                                        </td>
                                        <td>
                                            <FCKeditorV2:FCKeditor ID="txtNoiDung" runat="server" Height="300px">
                                            </FCKeditorV2:FCKeditor>
                                        </td>
                                    </tr>
                                </table>
                            </p>
                        </div>
                        <div class="clear">
                        </div>
                        <p>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTenSanPham"
                                Display="Dynamic" ValidationGroup="vdSanPham" ErrorMessage="Vui lòng nhập tiêu đề!"></asp:RequiredFieldValidator>
                        </p>
                        <p>
                            <asp:Button runat="server" ID="btnOK" CssClass="button" Text="Hoàn t&#7845;t" OnClick="btnOK_OnClick"
                                OnClientClick="return Check();" ValidationGroup="vdSanPham" />
                        </p>
                    </fieldset>
                    <div class="clear">
                    </div>
                    <!-- End .clear -->
                    </form>
                </div>
                <!-- End #tab2 -->
            </div>
            <!-- End .content-box-content -->
        </div>
        <!-- End .content-box -->
        <div id="footer">
            <small></small>
        </div>
        <!-- End #footer -->
    </div>

    <script type="text/javascript">
        function Check() {
            var e = document.getElementById('<%= txtMoTa.ClientID %>');
            if (e.value.length > 149) {
                alert('Mô tả không được nhập trên 150 ký tự');

                this.focus(e); 
                return false;
            }
        }
    
    </script>

</asp:Content>
